A device and a method for performing stack operations in a processing system, and especially a device and a method for allowing high-speed stack operations.
Many processing systems have memory modules in which a stack is implemented. A stack is a data structure in which a value most recently stored is the first value to be retrieved. Some stacks grow towards lower addresses/memory locations of a memory module and some stacks grow towards upper addresses of the memory module. Accordingly, the top of the stack is a memory location with the lowest or highest address of the stack where data is currently being stored.
There are two basic operations that are associated with a stackxe2x80x94a push operation in which a new value is added to the stack and a pop operation in which the value that is located at the top of the stack is retrieved. The new value is stored at a memory location following the top of the stack
Usually, a stack pointer points to the top of the stack or to a memory location that follows the top of the stack. The first type of stack pointer enables fast pop operations while the second type enables fast push operations. When a stack grown toward upper addresses and the stack pointer points to the memory location that follows the top of the stack, a pop operation involves decrementing the stack pointer and moving the value stored at the top of the stack and a push operation involves writing data to the memory location pointer by the stack pointer and incrementing the stack pointer. This prior art approach is relatively time consuming.
Stack operations are extensively used in accordance with interrupts. Usually a plurality of registers, holding the status of the processing system are pushed to the stack and eventually are popped from the stack. When many registers store the processing system status, the execution of an interrupt is very time consuming.
There is a need to provide a high speed and an improved device and method for performing stack operations.